home *** CD-ROM | disk | FTP | other *** search
- Option Public
-
- Sub Main
-
- ' OfficeTalk Fax Merge Macro v1.0 (Word Pro, Tested Release N70.941.0)
- ' -------------------------------------
- ' Written By Karl Flower & Greg Carrell
- ' (c) Sareen Software Plc 1996
- ' Created On 17th July 1996
- ' Modified On 18th July 1996
- ' -------------------------------------
-
- ' Find and read GFI FAX input string and handle errors
- .Application.FindAndReplace.FindString = "/$FAX"
- .Application.FindAndReplace.ReplaceString = ""
- .Application.FindAndReplace.MatchType = $LwpFindMatchWithinAWord
- FOUND = .Find()
- .InitFindAndReplace True
-
- If FOUND <> 0 Then
- Messagebox "No appropriate Fax Tag was found!", 48, "OT Fax Macro Error"
- Exit Sub
- End If
-
- ' Extract fax info from GFI FAX input string and handle errors
-
- GFISTRING$ = .Text.GetText($LwpGetObjectTypeParagraph, False)
- ORIGSTRING$ = GFISTRING$
-
- If Mid$(GFISTRING$, 1, 5) = "GFI$/" Then
-
- GFISTRING$ = Mid$(GFISTRING$, 6, Len(GFISTRING$) - 5)
- GFISTRING$ = Left$(GFISTRING$, Len(GFISTRING$) - 5)
-
- CURRMARK = Instr(1, GFISTRING$, "/$/")
- If CURRMARK <> 0 Then
- FAXNO$ = Left$(GFISTRING$, CURRMARK - 1)
- GFISTRING$ = Mid$(GFISTRING$, CURRMARK + 3, Len(GFISTRING$) - CURRMARK + 3)
- Else
- FAXNO$ = GFISTRING$
- GFISTRING$ = ""
- CONTACT$ = ""
- COMPANY$ = ""
- End If
-
- CURRMARK = Instr(1, GFISTRING$, "/$/")
- If CURRMARK <> 0 Then
- CONTACT$ = Left$(GFISTRING$, CURRMARK - 1)
- GFISTRING$ = Mid$(GFISTRING$, CURRMARK + 3, Len(GFISTRING$) - CURRMARK + 3)
- COMPANY$ = GFISTRING$
- Else
- CONTACT$ = GFISTRING$
- COMPANY$ = ""
- End If
-
- Else
- Messagebox "The Fax Tag is not correctly constructed!", 48, "OT Fax Macro Error"
- Exit Sub
- End If
-
- ' Remove fax info string from document
- .Type("[END]")
- .TYPE("[SHIFTUP]")
- .Type("[DEL]")
-
- ' Read default printer information
- PRINTER$ = .ActiveDocument.PrintManager.PrinterName
- PORT$ = .ActiveDocument.PrintManager.PrintDestination
-
- ' Change current printer to FaxMaker and Print Document
- .ActiveDocument.PrintManager.UseDefaultPrinter = False
- .ActiveDocument.PrintManager.PrinterName = "FaxMaker"
- .ActiveDocument.PrintManager.PrintDestination = "GFI"
- .ActiveDocument.PrintManager.UpdatePrinterChanges
- .Print
-
- ' Wait for GFI Fax client to initiate and then pass fax info
- CHANNEL = 0
- While CHANNEL = 0
- CHANNEL = DDEInitiate("FMCLIENT", "SENDFAX")
- Wend
- DDEPoke CHANNEL, "ADD", CONTACT$ + "|" + COMPANY$ + "|" + FAXNO$
- DDETerminate(CHANNEL)
-
- ' Set default printer back to original
- .ActiveDocument.PrintManager.PrinterName = PRINTER$
- .ActiveDocument.PrintManager.PrintDestination = PORT$
- .ActiveDocument.PrintManager.UpdatePrinterChanges
-
- End Sub
-